Integrals and Probability Density Functions Area Under a Curve The area under a curve between x = a x=a x = a and x = b x=b x = b (for a positive function) is called the integral of the function.
Figure: Example 1, 2 and 3
Details The area under a curve between x = a x=a x = a and x = b x=b x = b (for a positive function) is called the integral of the function and is denoted: ∫ a b f ( x ) d x \int_{a}^{b} f(x)dx ∫ a b f ( x ) d x when it exists.
The Antiderivative Given a function f f f , if there is another function F F F such that F ′ = f F'=f F ′ = f , we say that F F F is the antiderivative of f f f .
For a function f f f the antiderivative is denoted by ∫ f d x \int f dx ∫ fd x .
Note that if F F F is one antiderivative of f f f and C C C is a constant, then G = F + C G=F+C G = F + C is also an antiderivative.
It is therefore customary to always include the constant, e.g. ∫ x d x = 1 2 x 2 + C \int x dx=\displaystyle\frac{1}{2}x^2+C ∫ x d x = 2 1 x 2 + C .
Examples The antiderivative of x x x to a power raises the power by one and divides it by the new power:
∫ x n d x = 1 n + 1 x n + 1 + C \int x^n dx=\displaystyle\frac{1}{n+1}x^{n+1} +C ∫ x n d x = n + 1 1 x n + 1 + C
∫ e x d x = e x + C \int e^x dx=e^x+C ∫ e x d x = e x + C
∫ 1 x d x = ln ( x ) + C \int \displaystyle\frac{1}{x} dx=\ln(x)+C ∫ x 1 d x = ln ( x ) + C
∫ 2 x e x 2 d x = e x 2 + C \int 2xe^{x^2} dx=e^{x^2}+C ∫ 2 x e x 2 d x = e x 2 + C
The Fundamental Theorem of Calculus If f f f is a continuous function, and F ′ ( x ) = f ( x ) F'(x)=f(x) F ′ ( x ) = f ( x ) for x ∈ [ a , b ] x\in[a,b] x ∈ [ a , b ] , then ∫ a b f ( x ) d x = F ( b ) − F ( a ) \int_a^b f(x)dx=F(b)-F(a) ∫ a b f ( x ) d x = F ( b ) − F ( a )
Detail It is not too hard to see that the area under the graph of a positive function f f f on the interval [ a , b ] [a,b] [ a , b ] must be equal to the difference of the values of its antiderivative at a a a and b b b .
This also holds for functions which take on negative values and is formally stated below.
Fundamental theorem of calculus: If F F F is the antiderivative of the continuous function f f f , i.e. F ′ = f F'=f F ′ = f for x ∈ [ a , b ] x\in[a,b] x ∈ [ a , b ] , then ∫ a b f ( x ) d x = F ( b ) − F ( a ) \int_a^b f(x)dx=F(b)-F(a) ∫ a b f ( x ) d x = F ( b ) − F ( a ) .
This difference is often written as ∫ a b f d x \int_a^b f dx ∫ a b fd x or [ F ( x ) ] a b [F(x)]_a ^b [ F ( x ) ] a b .
Examples The area under the graph of x n x^n x n between 0 0 0 and 3 3 3 is ∫ 0 3 x n d x = [ 1 n + 1 x n + 1 ] 0 3 = 1 n + 1 3 n + 1 − 1 n + 1 0 n + 1 = 3 n + 1 n + 1 \int_0^3 x^n dx = [\displaystyle\frac{1}{n+1}x^{n+1}]_0 ^3=\displaystyle\frac{1}{n+1}3^{n+1}-\displaystyle\frac{1}{n+1}0^{n+1}=\displaystyle\frac{3^{n+1}}{n+1} ∫ 0 3 x n d x = [ n + 1 1 x n + 1 ] 0 3 = n + 1 1 3 n + 1 − n + 1 1 0 n + 1 = n + 1 3 n + 1
The area under the graph of e x e^x e x between 3 3 3 and 4 4 4 is ∫ 3 4 e x d x = [ e x ] 3 4 = e 4 − e 3 \int_3^4 e^x dx =[e^x]_3 ^4= e^4-e^3 ∫ 3 4 e x d x = [ e x ] 3 4 = e 4 − e 3
The area under the graph of 1 x \displaystyle\frac{1}{x} x 1 between 1 1 1 and a a a is ∫ 1 a 1 x d x = [ ln ( x ) ] 1 a = ln ( a ) − ln ( 1 ) = ln ( a ) \int_1^a \displaystyle\frac{1}{x} dx =[\ln(x)]_1 ^a= \ln(a)-\ln(1)=\ln(a) ∫ 1 a x 1 d x = [ ln ( x ) ] 1 a = ln ( a ) − ln ( 1 ) = ln ( a )
Density Functions The probability density function (p.d.f.
) and the cumulative distribution function (c.d.f.
).
Details If X X X is a random variable such that
P ( a ≤ X ≤ b ) = ∫ a b f ( x ) d x P(a\leq X\leq b)=\int\limits^{b}_{a}f(x)dx P ( a ≤ X ≤ b ) = a ∫ b f ( x ) d x
for some function f f f which satisfies f ( x ) ≥ 0 f(x)\geq0 f ( x ) ≥ 0 for all x x x and
∫ − ∞ ∞ f ( x ) d x = 1 \int\limits^\infty_{-\infty} f(x)dx = 1 − ∞ ∫ ∞ f ( x ) d x = 1
then f f f is said to be a probability density function (p.d.f.
) for X X X .
The function
F ( x ) = ∫ − ∞ x f ( t ) d t F(x)= \int\limits^{x}_{-\infty} f(t)dt F ( x ) = − ∞ ∫ x f ( t ) d t
is the cumulative distribution function (c.d.f.
) .
Examples Consider a random variable X X X from the uniform distribution, denoted by X ∼ U n f ( 0 , 1 ) X\sim Unf(0,1) X ∼ U n f ( 0 , 1 ) .
This distribution has density:
f ( x ) = { 1 if 0 ≤ x ≤ 1 0 e.w. f(x) = \begin{cases} 1 &\text{if } 0 \leq x \leq 1 \\ 0 &\text{e.w.} \end{cases} f ( x ) = { 1 0 if 0 ≤ x ≤ 1 e.w. The cumulative distribution function is given by:
P [ X ≤ x ] = ∫ − ∞ x f ( t ) d t = { 0 if x < 0 x if 0 ≤ x ≤ 1 1 else P[X\leq x] = \int\limits^{x}_{-\infty} f(t)dt = \begin{cases} 0 & \text{if } x < 0 \\ x & \text{if } 0 \leq x \leq 1 \\ 1 & \text{else} \end{cases} P [ X ≤ x ] = − ∞ ∫ x f ( t ) d t = ⎩ ⎨ ⎧ 0 x 1 if x < 0 if 0 ≤ x ≤ 1 else Suppose X ∼ P ( λ ) X \sim P(\lambda) X ∼ P ( λ ) , where X X X may denote the number of events per unit time.
The p.m.f.
of X X X is described by
p ( x ) = P [ X = x ] = e − λ λ x x ! for x = 0 , 1 , 2 , … p(x)=P[X=x]=e^{-\lambda}\displaystyle\frac{\lambda^x}{x!} \text{ for } x = 0,1,2,\dots p ( x ) = P [ X = x ] = e − λ x ! λ x for x = 0 , 1 , 2 , …
Let T T T denote the waiting time between events, or simply until the first event.
Consider the event T > t T>t T > t for some number t > 0 t>0 t > 0 .
If X ∼ p ( λ ) X\sim p(\lambda) X ∼ p ( λ ) denotes the number of events per unit time, then let X t X_t X t be the number of events during the time period for 0 0 0 through t t t .
Then it is natural to assume X t ∼ P ( λ t ) X_t \sim P(\lambda t) X t ∼ P ( λ t ) and it follows that T > t T>t T > t if and only if X t = 0 X_t=0 X t = 0 and we obtain P [ T > t ] = P [ X t = 0 ] = e − λ t P[T>t]=P[X_t=0]=e^{-\lambda t} P [ T > t ] = P [ X t = 0 ] = e − λ t .
It follows that the c.d.f.
of T T T is
F T ( t ) = P [ T ≤ t ] = 1 − P [ T > t ] = 1 − e − λ t for t > 0 F_T(t)=P[T\leq t]=1-P[T>t]=1-e^{-\lambda t} \text{ for } t > 0 F T ( t ) = P [ T ≤ t ] = 1 − P [ T > t ] = 1 − e − λ t for t > 0
The p.d.f.
of T T T is therefore
f T ( t ) = F T ′ ( t ) = d d t F T ( t ) = d d t ( 1 − e − λ t ) = 0 − e − λ t ⋅ ( − λ ) = λ e − λ t f_T(t)=F_T'(t)=\displaystyle\frac{d}{dt}F_T(t)=\displaystyle\frac{d}{dt}(1-e^{-\lambda t})=0-e^{- \lambda t} \cdot (-\lambda)=\lambda e^{-\lambda t} f T ( t ) = F T ′ ( t ) = d t d F T ( t ) = d t d ( 1 − e − λ t ) = 0 − e − λ t ⋅ ( − λ ) = λ e − λ t
for t ≥ 0 t \geq 0 t ≥ 0 and f T ( t ) = 0 for t < 0 f_T(t)=0 \text{ for } t < 0 f T ( t ) = 0 for t < 0
The resulting density
f ( t ) = { λ e − λ t for t ≥ 0 0 for t < 0 f(t) = \begin{cases} \lambda e^{-\lambda t} & \text{for } t \geq0 \\ 0 & \text{for } t<0 \end{cases} f ( t ) = { λ e − λ t 0 for t ≥ 0 for t < 0 describes the exponential distribution.
This distribution has the expected value
E [ T ] = ∫ − ∞ ∞ t f ( t ) d t = λ ∫ 0 ∞ t e − λ t d t E[T]=\int_{-\infty}^{\infty} tf(t)dt=\lambda \int_{0}^{\infty} t e^{-\lambda t}dt E [ T ] = ∫ − ∞ ∞ t f ( t ) d t = λ ∫ 0 ∞ t e − λ t d t
Let's use integration by parts (see below), i.e.: ∫ f g ′ = f g − ∫ f ′ g \int fg' = fg - \int f'g ∫ f g ′ = f g − ∫ f ′ g to solve that integral.
Let f = t f=t f = t and g ′ = e − λ t g'=e^{-\lambda t} g ′ = e − λ t .
Then f ′ = 1 f' = 1 f ′ = 1 and g = − e − λ t λ g=-\displaystyle\frac{e^{- \lambda t}}{\lambda} g = − λ e − λ t .
We obtain:
= λ ( [ − t e − λ t λ ] 0 ∞ − ∫ 0 ∞ − − e − λ t λ d t ) = λ ( ( 0 − 0 ) − [ e − λ t λ 2 ] 0 ∞ ) = − λ ( 0 − 1 λ 2 ) = 1 λ \begin{aligned} &= \lambda \left( \left[ \displaystyle\frac{-te^{-\lambda t}}{\lambda}\right]_{0}^{\infty} - \int_0^\infty - \displaystyle\frac{-e^{-\lambda t}}{\lambda} dt \right) \\ &= \lambda \left( (0 - 0) - \left[ \displaystyle\frac{e^{-\lambda t}}{\lambda^2} \right]_0^\infty \right) \\ &= -\lambda \left(0 - \displaystyle\frac{1}{\lambda^2}\right) \\ &= \displaystyle\frac{1}{\lambda} \end{aligned} = λ ( [ λ − t e − λ t ] 0 ∞ − ∫ 0 ∞ − λ − e − λ t d t ) = λ ( ( 0 − 0 ) − [ λ 2 e − λ t ] 0 ∞ ) = − λ ( 0 − λ 2 1 ) = λ 1 Probabilities In R: The Normal Distribution R has functions to compute values of probability density functions (p.d.f.
) and cumulative distribution functions (c.m.d.
) for most common distributions.
Details The p.d.f.
for the normal distribution is
p ( t ) = 1 2 π e − t 2 2 p(t)=\displaystyle\frac{1}{\sqrt{2\pi}}e^{-\displaystyle\frac{t^2}{2}} p ( t ) = 2 π 1 e − 2 t 2
The c.d.f.
for the normal distribution is
Φ ( x ) = ∫ − ∞ x 1 2 π e − t 2 2 d t \Phi(x)=\int_{-\infty}^x\displaystyle\frac{1}{\sqrt{2\pi}}e^{-\displaystyle\frac{t^2}{2}}dt Φ ( x ) = ∫ − ∞ x 2 π 1 e − 2 t 2 d t
Examples dnorm()
gives the value of the normal p.d.f.
pnorm()
gives the value of the normal c.d.f.
Some Rules of Integration Examples Using integration by parts we obtain:
∫ ln ( x ) x d x = 1 2 x 2 ln ( x ) − ∫ 1 2 x 2 ⋅ 1 x d x = 1 2 x 2 ln ( x ) − ∫ 1 2 x d x = 1 2 x 2 ln ( x ) − 1 4 x 2 \int \ln(x)x dx= \displaystyle\frac{1}{2}x^2\ln(x)-\int \displaystyle\frac{1}{2}x^2\cdot \displaystyle\frac{1}{x} dx = \displaystyle\frac{1}{2}x^2\ln(x)-\int \displaystyle\frac{1}{2}x dx=\displaystyle\frac{1}{2}x^2\ln(x)-\displaystyle\frac{1}{4}x^2 ∫ ln ( x ) x d x = 2 1 x 2 ln ( x ) − ∫ 2 1 x 2 ⋅ x 1 d x = 2 1 x 2 ln ( x ) − ∫ 2 1 x d x = 2 1 x 2 ln ( x ) − 4 1 x 2
Consider ∫ 1 2 2 x e x 2 d x \int_1^2 2xe^{x^2} dx ∫ 1 2 2 x e x 2 d x .
By setting x = g ( t ) = t x=g(t)=\sqrt{t} x = g ( t ) = t we obtain
∫ 1 2 2 x e x 2 d x = ∫ 1 4 2 t e t 1 2 t d t = ∫ 1 4 e t d t = e 4 − e \int_1^2 2xe^{x^2} dx = \int_1^4 2\sqrt{t}e^{t}\displaystyle\frac{1}{2\sqrt{t}}dt=\int_1^4 e^t dt=e^4-e ∫ 1 2 2 x e x 2 d x = ∫ 1 4 2 t e t 2 t 1 d t = ∫ 1 4 e t d t = e 4 − e
Handout The two most common "tricks" applied in integration are a) integration by parts and b) integration by substitution
a) Integration by parts
( f g ) ′ = f ′ g + f g ′ (fg)'=f'g+fg' ( f g ) ′ = f ′ g + f g ′
by integrating both sides of the equation we obtain:
f g = ∫ f ′ g d x + ∫ f g ′ d x ↔ ∫ f g ′ d x = f g − ∫ f ′ g d x fg=\int f'g dx + \int fg' dx \leftrightarrow \int fg' dx=fg-\int f'g dx f g = ∫ f ′ g d x + ∫ f g ′ d x ↔ ∫ f g ′ d x = f g − ∫ f ′ g d x
b) Integration by substitution
Consider the definite integral ∫ a b f ( x ) d x \int_a^b f(x) dx ∫ a b f ( x ) d x and let g g g be a one-to-one differential function for the interval ( c , d ) (c,d) ( c , d ) to ( a , b ) (a,b) ( a , b ) .
Then
∫ a b f ( x ) d x = ∫ c d f ( g ( y ) ) g ′ ( y ) d y \int_a^b f(x) dx=\int_c^d f(g(y))g'(y) dy ∫ a b f ( x ) d x = ∫ c d f ( g ( y )) g ′ ( y ) d y